﻿using ProductSystem.BLL.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ProductSystem.Web.Controllers
{
    public abstract class ManageControllerBase : Controller
    {
        protected ManageControllerBase()
            : base()
        {
            this.ValidateRequest = false;
        }

        /// <summary>
        /// 获取分页信息
        /// </summary>
        /// <returns></returns>
        protected PageInfo GetPageInfo()
        {
            int pageSize;   //每页行数
            if (Request.Cookies["PageSize"] != null)     //cookie如果不为空，将读取cookie作为pageSize的值
            {
                pageSize = Int32.Parse(Request.Cookies["PageSize"].Value);
            }
            else
            {
                pageSize = Request.QueryString.GetInt("pageSize", 10);
            }
            int curPage = Request.QueryString.GetInt("page", 1);//当前页
            if (Request["pageIndex"] != null)
            {
                curPage = int.Parse(Request["pageIndex"]);
            }
            PageInfo pageInfo = new PageInfo()
            {
                CurPage = curPage,
                PageSize = pageSize,
                TotalCount = 0
            };
            return pageInfo;
        }
    }
}